// 用户相关请求模块
import axios from '@/utils/request'

// 账号密码登录
export const login = (data) => {
  return axios.post('in/login', data)
  // return axios({
  //     method:'POST',
  //     url:'/app/v1_0/authorizations',
  //     data
  // })
}
// 钉钉登录
export const ddLogin = (authCode) => {
  return axios({
    method: 'POST',
    url: `in/ddLogin/${authCode}`
  })
}

// 获取当前登录用户个人信息
export const userInfo = () => {
  return axios.get('in/currentUserInfo')
}

// 用户管理
// 删除用户
export const deleteByUserId = (userId) => {
  return axios({
    method: 'POST',
    url: `user/deleteByUserId/${userId}`
  })
}

// 查询用户详情
export const findByUserId = (userId) => {
  return axios({
    method: 'GET',
    url: `user/findByUserId/${userId}`
  })
}

// 用户列表
export const pageUser = (params) => {
  return axios({
    method: 'GET',
    url: 'user/pageUser',
    params
  })
}
// 注册，新增用户
export const register = (data) => {
  return axios({
    method: 'POST',
    url: 'user/register',
    data
  })
}
// 编辑
export const updateUser = (data) => {
  return axios({
    method: 'POST',
    url: 'user/updateUser',
    data
  })
}

// 权限
// 分页
export const rolePage = (params) => {
  return axios({
    method: 'GET',
    url: 'authority/rolePage',
    params
  })
}
// 所有权限树形结构
export const allResources = (roleId) => {
  return axios({
    method: 'GET',
    url: 'authority/allResources'
  })
}

// 查询角色拥有的权限树形结构
export const findResourcesByRoleId = (roleId) => {
  return axios({
    method: 'GET',
    url: `authority/findResourcesByRoleId/${roleId}`
  })
}

// 删除角色
export const deleteRole = (roleId) => {
  return axios({
    method: 'POST',
    url: `authority/deleteRole/${roleId}`
  })
}
// 分配角色权限
export const assignRoleResource = (data) => {
  return axios({
    method: 'POST',
    url: 'authority/assignRoleResource',
    data
  })
}
// 直接删除角色对应权限
export const deleteRoleResource = (data) => {
  return axios({
    method: 'POST',
    url: 'authority/deleteRoleResource',
    data
  })
}
// 删除角色权限
// export const deleteResource = (resourceId) => {
//   return axios({
//     method: 'POST',
//     url: `authority/deleteResource/${resourceId}`
//   })
// }
// 新增角色
export const insertRole = (data) => {
  return axios({
    method: 'POST',
    url: 'authority/insertRole',
    data
  })
}
// 修改角色
export const updateRole = (data) => {
  return axios({
    method: 'POST',
    url: 'authority/updateRole',
    data
  })
}

// 所有角色
export const allRoles = () => {
  return axios({
    method: 'GET',
    url: 'authority/allRoles'
  })
}

// 获取待办list
export const myBeDone = (params) => {
  return axios({
    method: 'GET',
    url: '/bpm/myBeDone',
    params
  })
}

// 获取已办list
export const myDoneList = (params) => {
  return axios({
    method: 'GET',
    url: '/bpm/myDoneList',
    params
  })
}
// 获取审批历史list
export const getHistoryLook = (id) => {
  return axios({
    method: 'GET',
    url: '/bpm/processHistoryList/'+id,
  })
}

// 撤回
export const postWithdraw = (data) => {
  return axios({
    method: 'POST',
    url: '/bpm/withdrawProcess/',
    data
  })
}

// 菜单权限
export const getSideAuth = (params) => {
  return axios({
    method: 'GET',
    url: '/authority/findResourcesByRoleId',
    params
  })
}

//查询钉钉配置
export const getDingDingConfig=()=>{
  return axios({
    method: 'GET',
    url: 'in/getDingConfig'
  })
}


//同意
export const posApproveProcess = (data) => {
  return axios({
    method: 'POST',
    url: '/bpm/approveProcess',
    data
  })
}

//驳回
export const postrejectProcess = (data) => {
  return axios({
    method: 'POST',
    url: '/bpm/rejectProcess',
    data
  })
}


export const allEngTypeList = () => {
  return axios({
    method: 'GET',
    url: '/bpm/allEngTypeList',
  })
}


// 审批流程
export const allProcessList = () => {
  return axios({
    method: 'GET',
    url: '/bpm/allProcessList',
  })
}

// 审批查询

export const processDefineDetail = (key) => {
  return axios({
    method: 'GET',
    url: '/bpm/processDefineDetail/'+ key,
  })
}

// 提交审批节点
export const processSubmit = (data) => {
  return axios({
    method: 'POST',
    url: '/bpm/createProcessDefineAndDeploy',
    data
  })
}


// 查询人员
export const findAuditUsers = () => {
  return axios({
    method: 'GET',
    url: '/user/findAuditUsers',

  })
}


export const getDDDept =()=>{
  return axios({
    method: 'GET',
    url: '/user/ddDept'
  })
}

export const ddDeptUser =(id)=>{
  return axios({
    method: 'GET',
    url: '/user/ddDeptUser/'+id
  })
}


export const pageApprovalList =(params)=>{
  return axios({
    method: 'GET',
    url: '/bpm/approvalList',
    params
  })
}




export const usersByRoleId =(id)=>{
  return axios({
    method: 'GET',
    url: '/user/usersByRoleId/'+id,
  })
}


export const webSocketAddr =()=>{
  return axios({
    method: 'GET',
    url: '/user/getWebsocketAddr',
  })
}

export const addUserToRole = (data) => {
  return axios({
    method: 'POST',
    url: '/user/addUserToRole',
    data
  })
}

//获取当前用户签名
export const mySignFile = () => {
  return axios({
    method: 'GET',
    url: '/user/mySignFile'
  })
}










